home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 11 Learning / 04 Mommersteeg / Penny / SimplePredictor.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-23  |  1.8 KB  |  50 lines

  1. //----------------------------------------------------------------------------------------------
  2. // Sequential Prediction Demo: The positioning pattern
  3. // 
  4. // Author:  Fri Mommersteeg
  5. // Date:    10-09-2001
  6. // File:    SimplePredictor.h
  7. //----------------------------------------------------------------------------------------------
  8.  
  9. //----------------------------------------------------------------------------------------------
  10. //    A simple O(N^2) string-matching predictor (where N is the size of the window)
  11. //----------------------------------------------------------------------------------------------
  12.  
  13. #ifndef __SIMPLEPREDICTOR_H
  14. #define __SIMPLEPREDICTOR_H
  15.  
  16. //----------------------------------------------------------------------------------------------
  17. // Include files
  18. //----------------------------------------------------------------------------------------------
  19.  
  20. #include "predictor.h"
  21. #include "slidingwindow.h"
  22.  
  23. //----------------------------------------------------------------------------------------------
  24. // CSimplePredictor: predicts the next element in a sequence using string-matching prediction
  25. //----------------------------------------------------------------------------------------------
  26.  
  27. class CSimplePredictor : public CPredictor {
  28. public:
  29.     CSimplePredictor() { MinPerformance = 1; }
  30.  
  31.     // implementation of interface CPredictor
  32.     virtual void            Update(int NextElement)     { window.Add(NextElement); }
  33.     virtual bool            GetPrediction(int &Prediction);
  34.     virtual void            Reset() { window.SetSize(WindowSize); }
  35.  
  36.     // configuration methods
  37.     void                    Setup(int nWindowSize, int nMinPerformance);
  38.  
  39. protected:
  40.  
  41.     CSlidingWindow <int>    window;
  42.     int                        WindowSize;
  43.     int                        MinPerformance;
  44.  
  45. };
  46.  
  47. //----------------------------------------------------------------------------------------------
  48. #endif //__SIMPLEPREDICTOR_H
  49.  
  50.